---
id: "ref-value-assignment"
keywords: ["ref", "assign"]
name: ":="
summary: "This is the `ref value assignment` operator."
category: "operators"
---

This operator assigns a new value to a `ref`.

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let total = ref(0)
total := 1
```

```js
var total = {
  contents: 0,
};

total.contents = 1;
```

</CodeTab>

A `ref` is a builtin record type with a `mutable contents` field. Therefore the `:=` operator is just a shorthand version for the following code:

<CodeTab labels={["ReScript", "JS Output"]}>

```res
let total = ref(0)
total.contents = 1
```

```js
var total = {
  contents: 0,
};

total.contents = 1;
```

</CodeTab>
